package com.worthtech.billportal.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.worthtech.billportal.bean.CsDicEsb;
import com.worthtech.billportal.bean.CsDicEsbId;
import com.worthtech.billportal.form.PermissionForm;
import com.worthtech.billportal.service.PermissionService;
import com.worthtech.billportal.service.SaminfoService;

public class PermissionAction extends BaseAction {

	private PermissionService permissionService;
	private SaminfoService  saminfoService;
public SaminfoService getSaminfoService() {
		return saminfoService;
	}
	public void setSaminfoService(SaminfoService saminfoService) {
		this.saminfoService = saminfoService;
	}
public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		PermissionForm permissionForm = (PermissionForm) form;
		if ("index".equals(permissionForm.getAction())) {
			List permissionList = this.getPermissionService().getPermissionList(permissionForm.getMenuId());
			request.setAttribute("permissionList",permissionList);
			return mapping.findForward("list");
		}
		String action = permissionForm.getAction();
//		if("esb".equals(action)){
//			String type = request.getParameter("type");
//			if(type.equals("update")){
//				CsDicEsb esb = new CsDicEsb();
//				CsDicEsbId esbid = new CsDicEsbId();
//				esbid.setServiceSn(permissionForm.getServiceSn());
//				esbid.setServiceId(permissionForm.getServiceId());
//				esbid.setRequesterId(permissionForm.getRequesterId());
//				esbid.setBranchId(permissionForm.getBranchId());
//				esb.setChannelId(permissionForm.getChannelId());
//				esb.setProdes(permissionForm.getProdes());
//				esb.setValidflag(permissionForm.getValidflag());
//				esb.setVersionId(permissionForm.getVersionId());
//				return null;
//			}
//			List list = this.getSaminfoService().getListByHQL("CsDicEsb", 0, 0, "");
//			if(type.equals("show")){
//				if(list!=null&&list.size()>0){
//					CsDicEsb esb = (CsDicEsb)list.get(0);
//					permissionForm.setServiceSn(esb.getId().getServiceSn());
//					permissionForm.setServiceId(esb.getId().getServiceId());
//					permissionForm.setRequesterId(esb.getId().getRequesterId());
//					permissionForm.setBranchId(esb.getId().getBranchId());
//					permissionForm.setChannelId(esb.getChannelId());
//					permissionForm.setProdes(esb.getProdes());
//					permissionForm.setValidflag(esb.getValidflag());
//					permissionForm.setVersionId(esb.getVersionId());
//					return null;
//				}
//			}
//			request.setAttribute("log", list);
//			return null;
//		}
		
		return null;
	}	public PermissionService getPermissionService() {
		return permissionService;
	}

	public void setPermissionService(PermissionService permissionService) {
		this.permissionService = permissionService;
	}

}
